Generating a Type Library With MIDL

Microsoft s Interface Definition Language (IDL) now includes the complete Object Definition Language (ODL) syntax. This allows you to use the 32-bit MIDL compiler instead of MKTYPLIB.EXE to generate a type library and optional header files for an OLE application.

 

Note  When the documentation refers to an ODL file, this means a file that MKTYPLIB can parse. When it refers to an IDL file, this means a file that MIDL parses. This is strictly a naming convention. The MIDL compiler will parse an input file regardless of its filename extension.

 

The top-level element of the ODL syntax is the library statement (library block). Every other ODL statement, with the exception of the attributes that are applied to the library statement, must be defined within the library block.When the MIDL compiler sees a library block it generates a type library in much the same way as MKTYPLIB does. With a few exceptions, described in Differences Between MIDL and MKTYPLIB1GUG5CL, the statements within the library block should follow the same syntax as in the ODL language and MKTYPLIB.

You can apply ODL attributes to elements that are defined either inside or outside the library block. These attributes have no effect outside the library block unless the element they are applied to is referenced from within the library block. Statements inside the library block can reference an outside element either by using it as a base type, inheriting from it, or by referencing it on a line as shown:

<some IDL definitions including definitions for interface IFoo and struct bar>

[<some attributes>]

library a

interface IFoo;

struct bar;

...

};

 

If an element defined outside the library block is referenced within the library block, then its definition will be put into the generated type library.

The MIDL compiler treats the statements outside of a library block as a typical IDL file and parses those statements as it has always done. Normally, this means generating C-language stubs for an RPC application.

For more information about the general syntax for an ODL file see ODL File Syntax03AHG4.